package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.MyNotice;
import com.hl.sfzy.mapper.MyNoticeMapper;
import com.hl.sfzy.service.MyNoticeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyNoticeServiceImpl implements MyNoticeService {
	@Autowired
	private MyNoticeMapper myNoticeMapper;

	@Override
	public int add(MyNotice myNotice) {
		int add = myNoticeMapper.Insert(myNotice);
		return add;
	}

	@Override
	public int edit(MyNotice myNotice) {
		int edit = myNoticeMapper.Update(myNotice);
		return edit;
	}

	@Override
	public int remove(Integer myNoticeId) {
		int remove = myNoticeMapper.Delete(myNoticeId);
		return remove;
	}

	@Override
	public int removeBatch(Integer[] myNoticeIds) {
		int removeBatch = myNoticeMapper.DeleteBatch(myNoticeIds);
		return removeBatch;
	}

	@Override
	public PageInfo<MyNotice> findByPage(int pageNum, int pageSize, MyNotice myNotice) {
		PageHelper.startPage(pageNum,pageSize);
		List<MyNotice> list = myNoticeMapper.Select(myNotice);
		PageInfo<MyNotice> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public List<MyNotice> find() {
		List<MyNotice> find = myNoticeMapper.Select();
		return find;
	}

	@Override
	public MyNotice findById(Integer myNoticeId) {
		MyNotice findById = myNoticeMapper.SelectById(myNoticeId);
		return findById;
	}
}
